home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / amigae / gencodee_v22.lha / GenCodeE / sources / GenCodeE_v22 / GUIFile.e < prev    next >
Encoding:
Text File  |  1994-11-22  |  29.2 KB  |  1,234 lines

  1. OPT MODULE
  2.  
  3.  
  4. ->*****
  5. ->** External modules
  6. ->*****
  7. MODULE 'muibuilder' , 'libraries/muibuilder'
  8.  
  9. MODULE '*Variable'
  10. MODULE '*AuxProcs'
  11.  
  12.  
  13. ->*****
  14. ->** Exception handling
  15. ->*****
  16. RAISE    "OPEN"    IF    Open()        =    NIL    ,
  17.         "OUT"    IF    Fputs()        =    -1    ,
  18.         "OUT"    IF    FputC()        =    -1    ,
  19.         "MEM"    IF    String()    =    NIL
  20.  
  21.  
  22. ->*****
  23. ->** Object definitions
  24. ->*****
  25. EXPORT    OBJECT gui_file
  26.             PRIVATE
  27.                 file                :    LONG
  28.                 number_vars            :    LONG
  29.                 vars                :    PTR TO variable
  30.                 ident_length_max    :    LONG
  31.                 hook_funcs            :    LONG
  32.                 main_object_ident    :    PTR TO CHAR
  33.         ENDOBJECT
  34.  
  35.  
  36. /***********************************
  37. ** Opens the GUI file to generate **
  38. ***********************************/
  39. PROC open( filename : PTR TO CHAR , number_vars , vars : PTR TO variable , ident_length_max ) OF gui_file
  40.  
  41.     DEF i
  42.  
  43.     self.file := Open( filename , NEWFILE )
  44.     self.number_vars := number_vars
  45.     self.vars := vars
  46.     self.ident_length_max := ident_length_max
  47.     self.main_object_ident := vars[ 0 ].ident
  48.     self.hook_funcs := FALSE
  49.  
  50.     FOR i := 0 TO ( number_vars - 1 ) DO IF vars[ i ].type = TYPEVAR_HOOK THEN self.hook_funcs := TRUE
  51.  
  52. ENDPROC
  53.  
  54.  
  55. /************************************
  56. ** Closes the GUI file to generate **
  57. ************************************/
  58. PROC close() OF gui_file
  59.  
  60.     IF self.file THEN Close( self.file )
  61.  
  62. ENDPROC
  63.  
  64.  
  65. /******************************************
  66. ** Write to the GUI file its header part **
  67. ******************************************/
  68. PROC put_header( application , locale ) OF gui_file
  69.  
  70.     Fputs( self.file , 'OPT MODULE\n\n\n' )
  71.  
  72.     Fputs( self.file , '/*/////////////////////////////////////////////////////////////////////////////\n' )
  73.     Fputs( self.file , '///////////////////////////////////////////////////////////// Macro files /////\n' )
  74.     Fputs( self.file , '///////////////////////////////////////////////////////////////////////////////\n' )
  75.     Fputs( self.file , 'MACROS ''MUI.pma''\n*/\n\n\n' )
  76.  
  77.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  78.     Fputs( self.file , '->////////////////////////////////////////////////////// External modules /////\n' )
  79.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  80.     Fputs( self.file , 'MODULE ''muimaster'' , ''libraries/mui''\n' )
  81.     Fputs( self.file , 'MODULE ''tools/boopsi''\n' )
  82.     Fputs( self.file , 'MODULE ''utility/tagitem''' )
  83.  
  84.     Fputs( self.file , IF ( self.hook_funcs OR application ) THEN ' , ''utility/hooks''\n\n' ELSE '\n\n' )
  85.  
  86.     IF locale THEN Fputs( self.file , 'MODULE ''*Locale''\n\n\n' ) ELSE FputC( self.file , "\n" )
  87.  
  88. ENDPROC
  89.  
  90.  
  91. /*********************************************************
  92. ** Write to the GUI file the definitions of aux objects **
  93. *********************************************************/
  94. PROC put_aux_objects( environment , application ) OF gui_file
  95.  
  96.     DEF i
  97.  
  98.     IF environment
  99.  
  100.         Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  101.         Fputs( self.file , '->//////////////////////////////////////////////////// Object definitions /////\n' )
  102.         Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  103.  
  104.         IF application
  105.  
  106.             Fputs( self.file , 'EXPORT OBJECT app_arexx\n' )
  107.             Fputs( self.file , '\tcommands :\tPTR TO mui_command\n' )
  108.             Fputs( self.file , '\terror    :\thook\n' )
  109.             Fputs( self.file , 'ENDOBJECT\n\n' )
  110.  
  111.         ENDIF
  112.  
  113.     ENDIF
  114.  
  115.     IF self.hook_funcs
  116.  
  117.         IF environment
  118.  
  119.             Fputs( self.file , 'EXPORT OBJECT ' )
  120.             Fputs( self.file , self.main_object_ident )
  121.             Fputs( self.file , '_display\n' )
  122.  
  123.         ENDIF
  124.  
  125.         FOR i := 0 TO ( self.number_vars - 1 )
  126.  
  127.             IF self.vars[ i ].type = TYPEVAR_HOOK
  128.  
  129.                 FputC( self.file , "\t" )
  130.                 Fputs( self.file , self.vars[ i ].ident )
  131.                 indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  132.                 Fputs( self.file , ' :\thook\n' )
  133.  
  134.             ENDIF
  135.  
  136.         ENDFOR
  137.  
  138.         IF environment THEN Fputs( self.file , 'ENDOBJECT\n\n' ) ELSE FputC( self.file , "\n" )
  139.  
  140.     ENDIF
  141.  
  142. ENDPROC
  143.  
  144.  
  145. /*****************************************************************
  146. ** Write to the GUI file the definition of the generated object **
  147. *****************************************************************/
  148. PROC put_main_object( environment ) OF gui_file
  149.  
  150.     DEF i
  151.  
  152.     IF environment
  153.  
  154.         Fputs( self.file , 'EXPORT OBJECT ' )
  155.         Fputs( self.file , self.main_object_ident )
  156.         Fputs( self.file , '_obj\n' )
  157.  
  158.     ENDIF
  159.  
  160.     FOR i := 0 TO ( self.number_vars - 1 )
  161.  
  162.         IF self.vars[ i ].type = TYPEVAR_PTR
  163.  
  164.             FputC( self.file , "\t" )
  165.             Fputs( self.file , self.vars[ i ].ident )
  166.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  167.             Fputs( self.file , ' :\tPTR TO LONG\n' )
  168.  
  169.         ENDIF
  170.  
  171.     ENDFOR
  172.  
  173.     FOR i := 0 TO ( self.number_vars - 1 )
  174.  
  175.         IF ( self.vars[ i ].type = TYPEVAR_INT ) AND ( self.vars[ i ].type = TYPEVAR_BOOL )
  176.  
  177.             FputC( self.file , "\t" )
  178.             Fputs( self.file , self.vars[ i ].ident )
  179.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  180.             Fputs( self.file , ' :\tLONG\n' )
  181.  
  182.         ENDIF
  183.  
  184.     ENDFOR
  185.  
  186.     FOR i := 0 TO ( self.number_vars - 1 )
  187.  
  188.         IF self.vars[ i ].type = TYPEVAR_STRING
  189.  
  190.             FputC( self.file , "\t" )
  191.             Fputs( self.file , self.vars[ i ].ident )
  192.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  193.             Fputs( self.file , ' :\tPTR TO CHAR\n' )
  194.  
  195.         ENDIF
  196.  
  197.     ENDFOR
  198.  
  199.     FOR i := 0 TO ( self.number_vars - 1 )
  200.  
  201.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  202.  
  203.             FputC( self.file , "\t" )
  204.             Fputs( self.file , self.vars[ i ].ident )
  205.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  206.             Fputs( self.file , ' :\tPTR TO LONG\n' )
  207.  
  208.         ENDIF
  209.  
  210.     ENDFOR
  211.  
  212.     Fputs( self.file , IF environment THEN 'ENDOBJECT\n\n\n' ELSE '\n\n' )
  213.  
  214. ENDPROC
  215.  
  216.  
  217. /***********************************************************************************
  218. ** Write to the GUI file the definitions of the constants used with MUIM_ReturnID **
  219. ***********************************************************************************/
  220. PROC put_constants( environment ) OF gui_file
  221.  
  222.     DEF i , first_constant = TRUE , previous_ident : PTR TO CHAR , offset = 0
  223.  
  224.     FOR i := 0 TO ( self.number_vars - 1 )
  225.  
  226.         IF self.vars[ i ].type = TYPEVAR_IDENT
  227.  
  228.             IF first_constant
  229.  
  230.                 IF environment
  231.  
  232.                     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  233.                     Fputs( self.file , '->////////////////////////////////////////////////// Constant definitions /////\n' )
  234.                     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  235.                     Fputs( self.file , 'EXPORT ENUM\n' )
  236.  
  237.                 ENDIF
  238.  
  239.                 FputC( self.file , "\t" )
  240.                 Fputs( self.file , self.vars[ i ].ident )
  241.                 Fputs( self.file , ' = 1' )
  242.                 previous_ident := self.vars[ i ].ident
  243.                 first_constant := FALSE
  244.  
  245.             ELSE
  246.  
  247.                 indent_defs( self.file , previous_ident , self.ident_length_max + offset )
  248.                 Fputs( self.file , ' ,\n\t' )
  249.                 Fputs( self.file , self.vars[ i ].ident )
  250.                 offset := 4
  251.                 previous_ident := self.vars[ i ].ident
  252.  
  253.             ENDIF
  254.  
  255.         ENDIF
  256.  
  257.     ENDFOR
  258.  
  259.     IF first_constant = FALSE THEN Fputs( self.file , '\n\n\n' )
  260.  
  261. ENDPROC
  262.  
  263.  
  264. /********************************************************************************************************
  265. ** Write to the GUI file the definitions of the global variables (external ones used by notifications) **
  266. ********************************************************************************************************/
  267. PROC put_global_vars( environment , locale , catalog_name : PTR TO CHAR ) OF gui_file
  268.  
  269.     DEF i , first_global_var = TRUE
  270.  
  271.     FOR i := 0 TO ( self.number_vars - 1 )
  272.  
  273.         IF self.vars[ i ].type = TYPEVAR_EXTERNAL
  274.  
  275.             IF first_global_var
  276.  
  277.                 IF environment
  278.  
  279.                     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  280.                     Fputs( self.file , '->/////////////////////////////////////////// Global variable definitions /////\n' )
  281.                     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  282.  
  283.                 ENDIF
  284.  
  285.                 first_global_var := FALSE
  286.  
  287.             ENDIF
  288.  
  289.             Fputs( self.file , 'EXPORT DEF ' )
  290.             Fputs( self.file , self.vars[ i ].ident )
  291.             FputC( self.file , "\n" )
  292.  
  293.         ENDIF
  294.  
  295.     ENDFOR
  296.  
  297.     IF locale
  298.  
  299.         IF first_global_var
  300.  
  301.             IF environment
  302.  
  303.                 Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  304.                 Fputs( self.file , '->/////////////////////////////////////////// Global variable definitions /////\n' )
  305.                 Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  306.  
  307.             ENDIF
  308.  
  309.             first_global_var := FALSE
  310.  
  311.         ELSE
  312.  
  313.             FputC( self.file , "\n" )
  314.  
  315.         ENDIF
  316.  
  317.         Fputs( self.file , 'EXPORT DEF cat : PTR TO ' )
  318.         Fputs( self.file ,  catalog_name )
  319.         FputC( self.file , "\n" )
  320.  
  321.     ENDIF
  322.  
  323.     IF first_global_var = FALSE THEN Fputs( self.file , '\n\n' )
  324.  
  325. ENDPROC
  326.  
  327.  
  328. /*************************************************************
  329. ** Write to the GUI file the declaration of create() method **
  330. *************************************************************/
  331. PROC put_create_declaration( application ) OF gui_file
  332.  
  333.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  334.     Fputs( self.file , '->/////////// Creates one instance of one object or the whole application /////\n' )
  335.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  336.     Fputs( self.file , 'PROC create(' )
  337.  
  338.     IF application
  339.  
  340.         IF self.hook_funcs
  341.  
  342.             Fputs( self.file , ' display : PTR TO ' )
  343.             Fputs( self.file , self.main_object_ident )
  344.             Fputs( self.file , '_display ,\n            ' )
  345.  
  346.         ENDIF
  347.  
  348.         Fputs( self.file , ' icon  = NIL ,\n' )
  349.         Fputs( self.file , '             arexx = NIL : PTR TO app_arexx ,\n' )
  350.         Fputs( self.file , '             menu  = NIL ' )
  351.  
  352.     ELSE
  353.  
  354.         IF self.hook_funcs
  355.  
  356.             Fputs( self.file , ' display : PTR TO ' )
  357.             Fputs( self.file , self.main_object_ident )
  358.             Fputs( self.file , '_display ' )
  359.  
  360.         ENDIF
  361.  
  362.     ENDIF
  363.  
  364.     Fputs( self.file , ') OF ' )
  365.     Fputs( self.file , self.main_object_ident )
  366.     Fputs( self.file , '_obj\n\n' )
  367.  
  368. ENDPROC
  369.  
  370.  
  371. /********************************************************************
  372. ** Write to the GUI file the local declarations of create() method **
  373. ********************************************************************/
  374. PROC put_create_local_defs() OF gui_file
  375.  
  376.     DEF i , defs_string[ 70 ] : STRING , local_vars = FALSE
  377.  
  378.     FOR i := 0 TO ( self.number_vars - 1 )
  379.  
  380.         IF self.vars[ i ].type = TYPEVAR_LOCAL_PTR
  381.  
  382.             local_vars := TRUE
  383.  
  384.             IF ( EstrLen( defs_string ) + StrLen ( self.vars[ i ].ident ) ) <= 57
  385.  
  386.                 IF EstrLen( defs_string ) <> 0 THEN StrAdd( defs_string , ' , ' )
  387.                 StrAdd( defs_string , self.vars[ i ].ident )
  388.  
  389.             ELSE
  390.  
  391.                 Fputs( self.file, '\tDEF ' )
  392.                 Fputs( self.file, defs_string )
  393.                 FputC( self.file , "\n" )
  394.                 SetStr( defs_string , 0 )
  395.                 StrAdd( defs_string , self.vars[ i ].ident )
  396.  
  397.             ENDIF
  398.  
  399.         ENDIF
  400.             
  401.     ENDFOR
  402.  
  403.     IF EstrLen( defs_string ) <> 0
  404.  
  405.         Fputs( self.file , '\tDEF ' )
  406.         Fputs( self.file , defs_string )
  407.         FputC( self.file , "\n" )
  408.  
  409.     ENDIF
  410.  
  411.     IF local_vars THEN FputC( self.file , "\n" )
  412.  
  413. ENDPROC
  414.  
  415.  
  416. /********************************************************************
  417. ** Write to the GUI file the local declarations of create() method **
  418. ********************************************************************/
  419. PROC put_create_initialisations( locale , getstring_func : PTR TO CHAR ) OF gui_file
  420.  
  421.     DEF i , j , initialisations = FALSE
  422.     DEF strptr : PTR TO CHAR
  423.  
  424.     FOR i := 0 TO ( self.number_vars - 1 )
  425.  
  426.         IF self.vars[ i ].type =TYPEVAR_STRING
  427.  
  428.             initialisations := TRUE
  429.  
  430.             Fputs( self.file , '\tself.' )
  431.             Fputs( self.file , self.vars[ i ].ident )
  432.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  433.             Fputs( self.file , ' := ' )
  434.  
  435.             IF Char( self.vars[ i ].init ) <> 0
  436.  
  437.                 IF locale
  438.  
  439.                     Fputs( self.file , 'cat.' )
  440.                     Fputs( self.file , self.vars[ i ].init )
  441.                     FputC( self.file , "." )
  442.                     Fputs( self.file , getstring_func )
  443.                     Fputs( self.file , '()\n' )
  444.  
  445.                 ELSE
  446.  
  447.                     Fputs( self.file , string_convert( self.vars[ i ].init ) )
  448.                     FputC( self.file , "\n" )
  449.  
  450.                 ENDIF
  451.  
  452.             ELSE
  453.  
  454.                 Fputs( self.file , 'NIL\n' )
  455.  
  456.             ENDIF
  457.  
  458.         ENDIF
  459.  
  460.     ENDFOR
  461.  
  462.     FOR i := 0 TO ( self.number_vars - 1 )
  463.  
  464.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  465.  
  466.             initialisations := TRUE
  467.  
  468.             Fputs( self.file , '\tself.' )
  469.             Fputs( self.file , self.vars[ i ].ident )
  470.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  471.             Fputs( self.file , ' := [\n' )
  472.             strptr := self.vars[ i ].init
  473.  
  474.             FOR j := 1 TO self.vars[ i ].size
  475.  
  476.                 Fputs( self.file , '\t\t' )
  477.  
  478.                 IF locale
  479.  
  480.                     Fputs( self.file , 'cat.' )
  481.                     Fputs( self.file , strptr )
  482.                     FputC( self.file , "." )
  483.                     Fputs( self.file , getstring_func )
  484.                     Fputs( self.file , '() ,\n' )
  485.  
  486.                 ELSE
  487.  
  488.                     Fputs( self.file , string_convert( strptr ) )
  489.                     Fputs( self.file , ' ,\n' )
  490.  
  491.                 ENDIF
  492.  
  493.                 strptr := strptr + StrLen( strptr ) + 1
  494.  
  495.             ENDFOR
  496.  
  497.             Fputs( self.file , '\t\tNIL ]\n' )
  498.  
  499.         ENDIF
  500.  
  501.     ENDFOR
  502.  
  503.     IF initialisations THEN FputC( self.file , "\n" )
  504.  
  505. ENDPROC
  506.  
  507.  
  508. /************************************************
  509. ** Write to the GUI file all the creating code **
  510. ************************************************/
  511. PROC put_code( getstring_func : PTR TO CHAR , muistrings : PTR TO LONG ) OF gui_file
  512.  
  513.     DEF type , code
  514.     DEF indent_level = 1 , func_level = 0
  515.     DEF return = TRUE , objfunction = FALSE , inobj = FALSE
  516.  
  517.     Mb_GetNextCode( {type} , {code} )
  518.  
  519.     WHILE type <> -1
  520.  
  521.         SELECT type
  522.  
  523.             CASE TC_CREATEOBJ
  524.  
  525.                 indent_code( self.file , indent_level , return )
  526.                 Fputs( self.file , muistrings[ Val( code ) ] )
  527.                 Fputs( self.file , ' ,\n' )
  528.                 INC indent_level
  529.                 return := TRUE
  530.                 inobj := TRUE
  531.  
  532.                 IF Val( code ) = 113
  533.  
  534.                     indent_code( self.file , indent_level , return )
  535.                     Fputs( self.file , '( IF icon THEN MUIA_Application_DiskObject ELSE TAG_IGNORE ) , icon ,\n' )
  536.  
  537.                     indent_code( self.file , indent_level , return )
  538.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_Commands ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.commands ELSE NIL ) ,\n' )
  539.  
  540.                     indent_code( self.file , indent_level , return )
  541.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_RexxHook ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.error ELSE NIL ) ,\n' )
  542.  
  543.                     indent_code( self.file , indent_level , return )
  544.                     Fputs( self.file , '( IF menu THEN MUIA_Application_Menu ELSE TAG_IGNORE ) , menu ,\n' )
  545.  
  546.                 ENDIF
  547.  
  548.                 Mb_GetNextCode( {type} , {code} )
  549.  
  550.             CASE TC_ATTRIBUT
  551.  
  552.                 indent_code( self.file , indent_level , return )
  553.                 Fputs( self.file , muistrings[ Val( code ) ] )
  554.                 Fputs( self.file , ' , ')
  555.                 return := FALSE
  556.                 Mb_GetNextCode( {type} , {code} )
  557.  
  558.             CASE TC_END
  559.  
  560.                 DEC indent_level
  561.                 indent_code( self.file , indent_level , return )
  562.                 Fputs( self.file , muistrings[ Val( code ) ] )
  563.                 Fputs( self.file , '\n\n')
  564.                 inobj := FALSE
  565.                 return := TRUE
  566.                 Mb_GetNextCode( {type} , {code} )
  567.  
  568.             CASE TC_FUNCTION
  569.  
  570.                 indent_code( self.file , indent_level , return )
  571.  
  572.                 IF Val( code ) = 673
  573.  
  574.                     FputC( self.file , 34 )
  575.                     Mb_GetNextCode( {type} , {code} )
  576.                     Fputs( self.file , code )
  577.                     Mb_GetNextCode( {type} , {code} )
  578.                     Fputs( self.file , code )
  579.                     Mb_GetNextCode( {type} , {code} )
  580.                     Fputs( self.file , code )
  581.                     Mb_GetNextCode( {type} , {code} )
  582.                     Fputs( self.file , code )
  583.                     Mb_GetNextCode( {type} , {code} )
  584.                     Fputs( self.file , '" ,\n' )
  585.  
  586.                     return := TRUE
  587.  
  588.                 ELSE
  589.  
  590.                     INC func_level
  591.                     Fputs( self.file , muistrings[ Val( code ) ] )
  592.                     Fputs( self.file , '( ' )
  593.                     return := FALSE
  594.  
  595.                 ENDIF
  596.  
  597.                 Mb_GetNextCode( {type} , {code} )
  598.  
  599.             CASE TC_MUIARG_FUNCTION        ->    same as TC_FUNCTION
  600.  
  601.                 indent_code( self.file , indent_level , return )
  602.                 INC func_level
  603.                 Fputs( self.file , muistrings[ Val( code ) ] )
  604.                 Fputs( self.file , '( ' )
  605.                 return := FALSE
  606.                 Mb_GetNextCode( {type} , {code} )
  607.  
  608.             CASE TC_OBJFUNCTION
  609.  
  610.                 indent_code( self.file , indent_level , return )
  611.                 Fputs( self.file , muistrings[ Val( code ) ] )
  612.                 Fputs( self.file , '( ' )
  613.                 INC func_level
  614.                 return := FALSE
  615.                 objfunction := TRUE
  616.                 Mb_GetNextCode( {type} , {code} )
  617.  
  618.             CASE TC_MUIARG_OBJFUNCTION        ->    same as TC_OBJFUNCTION
  619.  
  620.                 indent_code( self.file , indent_level , return )
  621.                 Fputs( self.file , muistrings[ Val( code ) ] )
  622.                 Fputs( self.file , '( ' )
  623.                 INC func_level
  624.                 return := FALSE
  625.                 objfunction := TRUE
  626.                 Mb_GetNextCode( {type} , {code} )
  627.  
  628.             CASE TC_STRING
  629.  
  630.                 indent_code( self.file , indent_level , return )
  631.                 Fputs( self.file , string_convert( code ) )
  632.                 Mb_GetNextCode( {type} , {code} )
  633.  
  634.                 IF func_level > 0
  635.  
  636.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  637.                     return := FALSE
  638.  
  639.                 ELSE
  640.  
  641.                     Fputs( self.file , ' ,\n' )
  642.                     return := TRUE
  643.  
  644.                 ENDIF
  645.  
  646.             CASE TC_INTEGER
  647.  
  648.                 indent_code( self.file , indent_level , return )
  649.                 Fputs( self.file , code )
  650.                 Mb_GetNextCode( {type} , {code} )
  651.  
  652.                 IF func_level > 0
  653.  
  654.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  655.                     return := FALSE
  656.  
  657.                 ELSE
  658.  
  659.                     Fputs( self.file , ' ,\n' )
  660.                     return := TRUE
  661.  
  662.                 ENDIF
  663.  
  664.             CASE TC_CHAR
  665.  
  666.                 indent_code( self.file , indent_level , return )
  667.                 FputC( self.file , 34 )
  668.                 Fputs( self.file , code )
  669.                 Mb_GetNextCode( {type} , {code} )
  670.  
  671.                 IF func_level > 0
  672.  
  673.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , '" , ') ELSE FputC( self.file , 34 )
  674.                     return := FALSE
  675.  
  676.                 ELSE
  677.  
  678.                     Fputs( self.file , '" ,\n' )
  679.                     return := TRUE
  680.  
  681.                 ENDIF
  682.  
  683.             CASE TC_VAR_AFFECT
  684.  
  685.                 indent_code( self.file , indent_level , return )
  686.  
  687.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  688.  
  689.                     Fputs( self.file , 'self.' )
  690.  
  691.                 ENDIF
  692.  
  693.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  694.                 Fputs( self.file , ' := ')
  695.                 return := FALSE
  696.                 Mb_GetNextCode( {type} , {code} )
  697.  
  698.             CASE TC_VAR_ARG
  699.  
  700.                 indent_code( self.file , indent_level , return )
  701.  
  702.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  703.  
  704.                     Fputs( self.file , 'self.' )
  705.  
  706.                 ENDIF
  707.  
  708.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  709.                 Mb_GetNextCode( {type} , {code} )
  710.  
  711.                 IF func_level > 0
  712.  
  713.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  714.                     return := FALSE
  715.  
  716.                 ELSE
  717.  
  718.                     Fputs( self.file , ' ,\n')
  719.                     return := TRUE
  720.  
  721.                 ENDIF
  722.  
  723.             CASE TC_OBJ_ARG        ->    same as TC_VAR_ARG
  724.  
  725.                 indent_code( self.file , indent_level , return )
  726.  
  727.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  728.  
  729.                     Fputs( self.file , 'self.' )
  730.  
  731.                 ENDIF
  732.  
  733.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  734.                 Mb_GetNextCode( {type} , {code} )
  735.  
  736.                 IF func_level > 0
  737.  
  738.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  739.                     return := FALSE
  740.  
  741.                 ELSE
  742.  
  743.                     Fputs( self.file , ' ,\n')
  744.                     return := TRUE
  745.  
  746.                 ENDIF
  747.  
  748.             CASE TC_END_FUNCTION
  749.  
  750.                 indent_code( self.file , indent_level , return )
  751.                 DEC func_level
  752.                 Mb_GetNextCode( {type} , {code} )
  753.  
  754.                 IF func_level > 0
  755.  
  756.                     Fputs( self.file , ' )' )
  757.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' ,' )
  758.                     return := FALSE
  759.  
  760.                 ELSE
  761.  
  762.                     Fputs( self.file , IF objfunction THEN ' )\n\n' ELSE ' ) ,\n' )
  763.                     objfunction := FALSE
  764.                     return := TRUE
  765.  
  766.                 ENDIF
  767.  
  768.             CASE TC_BOOL
  769.  
  770.                 indent_code( self.file , indent_level , return )
  771.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  772.                 Mb_GetNextCode( {type} , {code} )
  773.  
  774.                 IF func_level > 0
  775.  
  776.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  777.                     return := FALSE
  778.  
  779.                 ELSE
  780.  
  781.                     Fputs( self.file , ' ,\n')
  782.                     return := TRUE
  783.  
  784.                 ENDIF
  785.  
  786.             CASE TC_MUIARG
  787.  
  788.                 indent_code( self.file , indent_level , return )
  789.                 Fputs( self.file , muistrings[ Val( code ) ] )
  790.                 Mb_GetNextCode( {type} , {code} )
  791.  
  792.                 IF func_level > 0
  793.  
  794.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  795.                     return := FALSE
  796.  
  797.                 ELSE
  798.  
  799.                     Fputs( self.file , ' ,\n')
  800.                     return := TRUE
  801.  
  802.                 ENDIF
  803.  
  804.             CASE TC_MUIARG_OBJ
  805.  
  806.                 indent_code( self.file , indent_level , return )
  807.                 Fputs( self.file , muistrings[ Val( code ) ] )
  808.                 Mb_GetNextCode( {type} , {code} )
  809.  
  810.                 IF inobj
  811.  
  812.                     Fputs( self.file , ' ,\n' )
  813.                     return := TRUE
  814.  
  815.                 ELSE
  816.  
  817.                     IF func_level > 0
  818.  
  819.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  820.                         return := FALSE
  821.  
  822.                     ELSE
  823.  
  824.                         Fputs( self.file , '\n\n')
  825.                         return := TRUE
  826.  
  827.                     ENDIF
  828.  
  829.                 ENDIF
  830.  
  831.             CASE TC_MUIARG_ATTRIBUT        ->    same as TC_MUIARG_OBJ
  832.  
  833.                 indent_code( self.file , indent_level , return )
  834.                 Fputs( self.file , muistrings[ Val( code ) ] )
  835.                 Mb_GetNextCode( {type} , {code} )
  836.  
  837.                 IF inobj
  838.  
  839.                     Fputs( self.file , ' ,\n' )
  840.                     return := TRUE
  841.  
  842.                 ELSE
  843.  
  844.                     IF func_level > 0
  845.  
  846.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  847.                         return := FALSE
  848.  
  849.                     ELSE
  850.  
  851.                         Fputs( self.file , '\n\n')
  852.                         return := TRUE
  853.  
  854.                     ENDIF
  855.  
  856.                 ENDIF
  857.  
  858.             CASE TC_EXTERNAL_FUNCTION
  859.  
  860.                 indent_code( self.file , indent_level , return )
  861.                 Fputs( self.file , 'display.' )
  862.                 Fputs( self.file , code )
  863.                 Mb_GetNextCode( {type} , {code} )
  864.  
  865.                 IF func_level > 0
  866.  
  867.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  868.                     return := FALSE
  869.  
  870.                 ELSE
  871.  
  872.                     Fputs( self.file , ' ,\n')
  873.                     return := TRUE
  874.  
  875.                 ENDIF
  876.  
  877.             CASE TC_LOCALESTRING
  878.  
  879.                 indent_code( self.file , indent_level , return )
  880.                 Fputs( self.file , 'getMBstring( cat.')
  881.                 Fputs( self.file ,  code )
  882.                 FputC( self.file , "." )
  883.                 Fputs( self.file , getstring_func )
  884.                 Fputs( self.file , '() )' )
  885.                 Mb_GetNextCode( {type} , {code} )
  886.  
  887.                 IF func_level > 0
  888.  
  889.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  890.                     return := FALSE
  891.  
  892.                 ELSE
  893.  
  894.                     Fputs( self.file , ' ,\n')
  895.                     return := TRUE
  896.  
  897.                 ENDIF
  898.  
  899.             CASE TC_LOCALECHAR
  900.  
  901.                 indent_code( self.file , indent_level , return )
  902.                 Fputs( self.file , 'Char( cat.')
  903.                 Fputs( self.file ,  code )
  904.                 FputC( self.file , "." )
  905.                 Fputs( self.file , getstring_func )
  906.                 Fputs( self.file , '() )')
  907.                 Mb_GetNextCode( {type} , {code} )
  908.  
  909.                 IF func_level > 0
  910.  
  911.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  912.                     return := FALSE
  913.  
  914.                 ELSE
  915.  
  916.                     Fputs( self.file , ' ,\n')
  917.                     return := TRUE
  918.  
  919.                 ENDIF
  920.  
  921.         ENDSELECT
  922.  
  923.     ENDWHILE
  924.  
  925. ENDPROC
  926.  
  927.  
  928. /*****************************************************
  929. ** Write to the GUI file the end of create() method **
  930. *****************************************************/
  931. PROC put_create_end() OF gui_file
  932.  
  933.     Fputs( self.file , 'ENDPROC self.' )
  934.     Fputs( self.file , self.main_object_ident )
  935.     Fputs( self.file , '\n\n\n' )
  936.  
  937. ENDPROC
  938.  
  939.  
  940. /***********************************************
  941. ** Write to the GUI file the dispose() method **
  942. ***********************************************/
  943. PROC put_dispose_method() OF gui_file
  944.  
  945.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  946.     Fputs( self.file , '->////////////////////////// Disposes the object or the whole application /////\n' )
  947.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  948.     Fputs( self.file , 'PROC dispose() OF ' )
  949.     Fputs( self.file , self.main_object_ident )
  950.     Fputs( self.file , '_obj IS ( IF self.' )
  951.     Fputs( self.file , self.main_object_ident )
  952.     Fputs( self.file , ' THEN Mui_DisposeObject( self.' )
  953.     Fputs( self.file , self.main_object_ident )
  954.     Fputs( self.file , ' ) ELSE NIL )\n\n\n' )
  955.  
  956. ENDPROC
  957.  
  958.  
  959. /*************************************************************************
  960. ** Write to the GUI file the declaration of init_notifications() method **
  961. *************************************************************************/
  962. PROC put_init_notifications_declaration() OF gui_file
  963.  
  964.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  965.     Fputs( self.file , '->/////////////////////// Initializes all the notifications of one object /////\n' )
  966.     Fputs( self.file , '->/////////////////////////////////////////// or of the whole application /////\n' )
  967.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  968.     Fputs( self.file , 'PROC init_notifications(' )
  969.  
  970.     IF self.hook_funcs
  971.  
  972.         Fputs( self.file , ' display : PTR TO ' )
  973.         Fputs( self.file , self.main_object_ident )
  974.         Fputs( self.file , '_display ' )
  975.  
  976.     ENDIF
  977.  
  978.     Fputs( self.file , ') OF ' )
  979.     Fputs( self.file , self.main_object_ident )
  980.     Fputs( self.file , '_obj\n\n' )
  981.  
  982. ENDPROC
  983.  
  984.  
  985. /************************************************
  986. ** Write to the GUI file all the notifications **
  987. ************************************************/
  988. PROC put_notifications( muistrings : PTR TO LONG , getstring_func : PTR TO CHAR ) OF gui_file
  989.  
  990.     DEF type , code , indent = FALSE
  991.  
  992.     Mb_GetNextNotify( {type} , {code} )
  993.  
  994.     WHILE ( type <> -1 )
  995.  
  996.         IF indent THEN Fputs( self.file , '\t\t' )
  997.  
  998.         SELECT type
  999.  
  1000.             CASE TC_BEGIN_NOTIFICATION
  1001.  
  1002.                 Fputs( self.file , '\tdomethod( self.' )
  1003.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  1004.                 Fputs( self.file , ' , [\n' )
  1005.                 indent := TRUE
  1006.                 Mb_GetNextNotify( {type} , {code} )
  1007.  
  1008.             CASE TC_END_NOTIFICATION
  1009.  
  1010.                 Fputs( self.file , ' ] )\n\n' )
  1011.                 indent := FALSE
  1012.                 Mb_GetNextNotify( {type} , {code} )
  1013.  
  1014.             CASE TC_FUNCTION
  1015.  
  1016.                 FputC( self.file , "\t" )
  1017.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1018.                 Fputs( self.file , '( ' )
  1019.                 indent := FALSE
  1020.                 Mb_GetNextNotify( {type} , {code} )
  1021.  
  1022.             CASE TC_END_FUNCTION
  1023.  
  1024.                 Fputs( self.file , ')\n\n' )
  1025.                 indent := FALSE
  1026.                 Mb_GetNextNotify( {type} , {code} )
  1027.  
  1028.             CASE TC_STRING
  1029.  
  1030.                 Fputs( self.file , string_convert( code ) )
  1031.                 Mb_GetNextNotify( {type} , {code} )
  1032.  
  1033.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1034.  
  1035.                     indent := TRUE
  1036.                     Fputs( self.file , ' ,\n' )
  1037.  
  1038.                 ELSE
  1039.  
  1040.                     indent := FALSE
  1041.  
  1042.                 ENDIF
  1043.  
  1044.             CASE TC_LOCALESTRING
  1045.  
  1046.                 Fputs( self.file , 'getMBstring( cat.')
  1047.                 Fputs( self.file ,  code )
  1048.                 FputC( self.file , "." )
  1049.                 Fputs( self.file , getstring_func )
  1050.                 Fputs( self.file , '() )' )
  1051.                 Mb_GetNextNotify( {type} , {code} )
  1052.  
  1053.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1054.  
  1055.                     indent := TRUE
  1056.                     Fputs( self.file , ' ,\n' )
  1057.  
  1058.                 ELSE
  1059.  
  1060.                     indent := FALSE
  1061.  
  1062.                 ENDIF
  1063.  
  1064.             CASE TC_INTEGER
  1065.  
  1066.                 Fputs( self.file , code )
  1067.                 Mb_GetNextNotify( {type} , {code} )
  1068.  
  1069.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1070.  
  1071.                     indent := TRUE
  1072.                     Fputs( self.file , ' ,\n' )
  1073.  
  1074.                 ELSE
  1075.  
  1076.                     indent := FALSE
  1077.  
  1078.                 ENDIF
  1079.  
  1080.             CASE TC_CHAR
  1081.  
  1082.                 FputC( self.file , 34)
  1083.                 Fputs( self.file , code )
  1084.                 FputC( self.file , 34)
  1085.                 Mb_GetNextNotify( {type} , {code} )
  1086.  
  1087.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1088.  
  1089.                     indent := TRUE
  1090.                     Fputs( self.file , ' ,\n' )
  1091.  
  1092.                 ELSE
  1093.  
  1094.                     indent := FALSE
  1095.  
  1096.                 ENDIF
  1097.  
  1098.             CASE TC_BOOL
  1099.  
  1100.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  1101.                 Mb_GetNextNotify( {type} , {code} )
  1102.  
  1103.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1104.  
  1105.                     indent := TRUE
  1106.                     Fputs( self.file , ' ,\n' )
  1107.  
  1108.                 ELSE
  1109.  
  1110.                     indent := FALSE
  1111.  
  1112.                 ENDIF
  1113.  
  1114.             CASE TC_VAR_ARG
  1115.  
  1116.                 Fputs( self.file , 'self.')
  1117.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  1118.                 Mb_GetNextNotify( {type} , {code} )
  1119.  
  1120.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1121.  
  1122.                     indent := TRUE
  1123.                     Fputs( self.file , ' ,\n' )
  1124.  
  1125.                 ELSE
  1126.  
  1127.                     indent := FALSE
  1128.  
  1129.                 ENDIF
  1130.  
  1131.             CASE TC_MUIARG
  1132.  
  1133.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1134.                 indent := FALSE
  1135.                 Mb_GetNextNotify( {type} , {code} )
  1136.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1137.  
  1138.             CASE TC_MUIARG_OBJ        ->    same as TC_MUIARG
  1139.  
  1140.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1141.                 indent := FALSE
  1142.                 Mb_GetNextNotify( {type} , {code} )
  1143.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1144.  
  1145.             CASE TC_MUIARG_ATTRIBUT
  1146.  
  1147.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1148.                 Mb_GetNextNotify( {type} , {code} )
  1149.  
  1150.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1151.  
  1152.                     indent := TRUE
  1153.                     Fputs( self.file , ' ,\n' )
  1154.  
  1155.                 ELSE
  1156.  
  1157.                     indent := FALSE
  1158.  
  1159.                 ENDIF
  1160.  
  1161.             CASE TC_EXTERNAL_CONSTANT
  1162.  
  1163.                 Fputs( self.file , code )
  1164.                 Mb_GetNextNotify( {type} , {code} )
  1165.  
  1166.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1167.  
  1168.                     indent := TRUE
  1169.                     Fputs( self.file , ' ,\n' )
  1170.  
  1171.                 ELSE
  1172.  
  1173.                     indent := FALSE
  1174.  
  1175.                 ENDIF
  1176.  
  1177.             CASE TC_EXTERNAL_FUNCTION
  1178.  
  1179.                 Fputs( self.file , 'display.' )
  1180.                 Fputs( self.file , code )
  1181.                 Mb_GetNextNotify( {type} , {code} )
  1182.  
  1183.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1184.  
  1185.                     indent := TRUE
  1186.                     Fputs( self.file , ' ,\n' )
  1187.  
  1188.                 ELSE
  1189.  
  1190.                     indent := FALSE
  1191.  
  1192.                 ENDIF
  1193.  
  1194.             CASE TC_EXTERNAL_VARIABLE
  1195.  
  1196.                 Fputs( self.file , code )
  1197.                 Mb_GetNextNotify( {type} , {code} )
  1198.  
  1199.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1200.  
  1201.                     indent := TRUE
  1202.                     Fputs( self.file , ' ,\n' )
  1203.  
  1204.                 ELSE
  1205.  
  1206.                     indent := FALSE
  1207.  
  1208.                 ENDIF
  1209.  
  1210.         ENDSELECT
  1211.  
  1212.     ENDWHILE
  1213.  
  1214. ENDPROC
  1215.  
  1216.  
  1217. /*****************************************************************
  1218. ** Write to the GUI file the end of init_notifications() method **
  1219. *****************************************************************/
  1220. PROC put_init_notifications_end() OF gui_file IS Fputs( self.file , 'ENDPROC\n\n\n' )
  1221.  
  1222.  
  1223. /*************************************************
  1224. ** Write to the GUI file getMBstring() function **
  1225. *************************************************/
  1226. PROC put_aux_funcs() OF gui_file
  1227.  
  1228.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  1229.     Fputs( self.file , '->//////////// Special GetString() function for MUIBuilder generated code /////\n' )
  1230.     Fputs( self.file , '->/////////////////////////////////////////////////////////////////////////////\n' )
  1231.     Fputs( self.file , 'PROC getMBstring( local_string : PTR TO CHAR ) RETURN ( IF local_string[ 1 ] = "\\0" THEN ( local_string + 2 ) ELSE local_string )\n' )
  1232.  
  1233. ENDPROC
  1234.